package ar.uba.fi.tonyvaliente.signature;

/**
 * Implementacion de la funcion de hash Fold & Add
 */
public class FoldAndAddHashFunction extends HashFunction {

	public FoldAndAddHashFunction(int length) {
		super(length);
	}

	@Override
	public Number hash(String data) {
		
		Long hash = 0L;

		for (int i = 0; i < data.length(); i++) {
			hash += Character.getNumericValue(data.charAt(i));
			hash *= this.getSeed();
		}
		
		return Math.abs(hash%this.getLength());
	}

}
